/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSTechnique.h
 *
 *  Created on: 2010/03/08
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#ifndef RSTECHNIQUE_H_
#define RSTECHNIQUE_H_

#include "RSElement.h"

namespace Realsphere {

    class RSTechnique : public Realsphere::RSElement {
        Q_OBJECT
        Q_PROPERTY ( QString _attr_profile READ Profile WRITE SetProfile )
        Q_PROPERTY ( QString _attr_xmlns READ XMLNS WRITE SetXMLNS )
        public:
            RSTechnique ( RSTechniqueProfileType rTechniqueProfileType,
                          const QString& rProfile,
                          const QString& rXMLNS = QString::null );

            virtual ~RSTechnique ();

        public:
            RSTechniqueProfileType      TechniqueProfileType () const;
            QString                     Profile () const;
            QString                     XMLNS () const;
            RSTechniqueElement*         GetTechniqueElement ( unsigned int rIndex ) const;
            RSTechniqueElement*         GetTechniqueElement ( const QString& rScopeId ) const;
            RSTechniqueElements         TechniqueElements () const;
            RSTechniqueElementsIterator TechniqueElementsIterator () const;
            int                         IndexOf ( RSTechniqueElement* rTechniqueElement );
            unsigned int                TechniqueElementsSize ();
            bool                        IsRootElement () const;

        public slots:
            void                        SetProfile ( const QString& rProfile, bool rEmit = true );
            void                        SetXMLNS ( const QString& rXMLNS, bool rEmit = true );
            RSError                     AddTechniqueElement ( RSTechniqueElement* rTecnhiqueELement );
            RSError                     RemoveTechniqueElement ( RSTechniqueElement* rTechniqueElement );
            RSError                     RemoveTechniqueElement ( unsigned int rIndex );
            RSError                     RemoveTechniqueElement ( const QString& rScopeId );

        signals:
            void                        ProfileChanged ( const QString& rProfile );
            void                        XMLNSChanged ( const QString& rXMLNS );
            void                        TechniqueElementAdded ( RSTechniqueElement* rTechniqueElement );
            void                        TechniqueElementRemoved ( RSTechniqueElement* rTechniqueElement );
            void                        TechniqueChanged ();

        protected:
            RSError                     BeforeAddChildElement ( RSElement* rChild );
            bool                        AfterAddChildElement ( RSElement* rChild );
            bool                        AfterRemoveChildElement ( RSElement* rChild );

        public:
            static QString                TechniqueProfileTypeToTag ( RSTechniqueProfileType rTechniqueProfileType );
            static RSTechniqueProfileType TechniqueProfileTagToType ( const QString& rTag );

        private:
            RSTechniqueProfileType      mTechniqueProfileType;
            QString                     mProfile;
            QString                     mXMLNS;
            RSTechniqueElements         mTechniqueElements;
    };

}

#endif /* RSTECHNIQUE_H_ */
